package com.example.baselibrary.base;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

@SuppressWarnings("ALL")
public abstract class BaseActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //设置布局界面
        setContentView(getLayoutById());
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
        //初始化头部
        initTitle();
        //初始化布局
        initViews();
        //初始化数据
        initData();
    }

    protected abstract int getLayoutById();

    protected abstract void initData();

    protected abstract void initViews();

    protected abstract void initTitle();


    protected void startActivity(Class<?> cls) {
        startActivity(new Intent(this, cls));
    }

    protected <T extends View> T viewById(int viewId) {
        return (T) findViewById(viewId);
    }
}
